package com.relife.sys.service;

import java.io.IOException;
import java.util.zip.ZipInputStream;

import com.relife.core.entity.FileEntity;
import com.relife.core.service.BaseService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



@Service("deploymentService")
@Transactional
public class DeploymentService extends BaseService {
	@Autowired
	private RepositoryService repositoryService;

	public void zipDeployment(FileEntity file) throws IOException {
		ZipInputStream zi = new ZipInputStream(file.getFile().getInputStream());
		Deployment deployment = repositoryService.createDeployment().addZipInputStream(zi).deploy();
		log.info("部署ID：" + deployment.getId() + "部署时间：" + deployment.getDeploymentTime());
	}

	/**
	 * 
	 * @param id
	 */
	public void delDeployment(String id) {
		repositoryService.deleteDeployment(id, true);
	}

}
